package org.jeecg.modules.wechat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.wechat.entity.WxUser;

import java.util.List;

/**
 * @Description: 微信用户表
 * @Author: jeecg-boot
 * @Date:   2020-11-11
 * @Version: V1.0
 */
public interface WxUserMapper extends BaseMapper<WxUser> {

    /**
     * TODO: 增加积分
     *
     *
     * @author ZhangHaoyu
     * @param openId  用户openid
    * @param score 积分
     * @return void
     */
    @Update("update `wx_user` set score = score + #{incrScore} where open_id = #{openId}")
    void incrScore(@Param("openId") String openId, @Param("incrScore") int score);

    /**
     * TODO: 减少积分
     *
     *
     * @author ZhangHaoyu
     * @param openId  用户openid
     * @param score 积分
     * @return void
     */
    @Update("update `wx_user` set score = score - #{incrScore} where open_id = #{openId}")
    void decrScore(@Param("openId") String openId, @Param("incrScore") int score);

    /**
     * TODO: 获取wx普通用户信息
     *
     * @author: Zhang hao yu
     * @param page 分页
     * @return: java.util.List<org.jeecg.modules.wechat.entity.WxUser>
     */
    @Select("select * from wx_user")
    List<WxUser> queryWxUser(Page<WxUser> page);
}
